home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / VPRINTF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1000 b   |  29 lines

  1. /* vprintf.c --- p 479 */
  2. #include <stdio.h>
  3. #include <stdarg.h>                  /* ANSI C compatible */
  4. void error_handler(char *,...);
  5. char filename[80] = "COMMAND.COM";
  6. main()
  7. {
  8.     int offset = 0x232A;
  9.             /* Call the error handler to print an error message.
  10.              * First just a single line. Then a more detailed
  11.              * message with more arguments. */
  12.     error_handler("System error\n");
  13.     error_handler("File %s at offset %x\n", filename, offset);
  14. }
  15.                     /*--------------------------------*/
  16.         /* error_handler: accepts variable number of arguments
  17.          *            and prints messages */
  18. void error_handlerf(char *my_format,...)
  19. {
  20.     va_list arg_pointer;
  21.             /* Use va_start macro to get to the start of the
  22.              * variable number of arguments. This will alter the
  23.              * pointer arg_pointer to point to the list of
  24.              * variables to be printed. */
  25.     va_start(arg_pointer, my_format);
  26.     vprintf(my_format, arg_pointer);
  27.             /* Use the va_end macro to reset the arg_pointer */
  28.     va_end(arg_pointer);
  29. }